package com.aidex.biz.service.impl;

import java.util.List;

import com.aidex.biz.domain.Customer;
import com.aidex.common.annotation.DataScope;
import com.aidex.common.core.domain.R;
import com.aidex.common.core.page.PageDomain;
import com.aidex.common.utils.StringUtils;
import com.aidex.common.utils.sql.SqlUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.domain.entity.SysUser;
import com.aidex.common.core.domain.entity.SysDept;
import com.aidex.common.core.service.BaseServiceImpl;
import com.aidex.framework.cache.DeptUtils;
import com.aidex.framework.cache.UserUtils;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.aidex.biz.mapper.CustomerXiezuMapper;
import com.aidex.biz.domain.CustomerXiezu;
import com.aidex.biz.service.CustomerXiezuService;
import org.springframework.transaction.annotation.Transactional;
import com.aidex.common.utils.NumberUtils;

/**
 * 客户协助Service业务层处理
 * @author sean
 * @email 2074844820@qq.com
 * @date 2023-11-29
 */
@Service
@Transactional(readOnly = true)
public class CustomerXiezuServiceImpl extends BaseServiceImpl<CustomerXiezuMapper, CustomerXiezu> implements CustomerXiezuService
{
    private static final Logger log = LoggerFactory.getLogger(CustomerXiezuServiceImpl.class);

    /**
     * 获取单条数据
     * @param customerXiezu 客户协助
     * @return 客户协助
     */
    @Override
    public CustomerXiezu get(CustomerXiezu customerXiezu)
    {
        CustomerXiezu dto = super.get(customerXiezu);
        return dto;
    }

    /**
     * 获取单条数据
     * @param id 客户协助id
     * @return 客户协助
     */
    @Override
    public CustomerXiezu get(String id)
    {
        CustomerXiezu dto = super.get(id);
        return dto;
    }


    /**
     * 查询客户协助列表
     * @param customerXiezu 客户协助
     * @return 客户协助
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public List<CustomerXiezu> findList(CustomerXiezu customerXiezu)
    {
        return super.findList(customerXiezu);
    }

    /**
     * 分页查询客户协助列表
     * @param customerXiezu 客户协助
     * @return 客户协助
     */
    @Override
    @DataScope(userAlias = "a",deptAlias = "a")
    public PageInfo<CustomerXiezu> findPage(CustomerXiezu customerXiezu)
    {
        return super.findPage(customerXiezu);
    }

    /**
     * 保存客户协助
     * @param customerXiezu
     * @return 结果
     */
    @Override
    public boolean save(CustomerXiezu customerXiezu)
    {
        return super.save(customerXiezu);
    }


    /**
     * 删除客户协助信息
     * @param customerXiezu
     * @return 结果
     */
    @Override
    public boolean remove(CustomerXiezu customerXiezu)
    {
        return super.remove(customerXiezu);
    }

    /**
     * 批量删除客户协助
     * @param ids 需要删除的客户协助ID
     * @return 结果
     */
    @Transactional(readOnly = false)
    @Override
    public int deleteCustomerXiezuByIds(String[] ids)
    {
        return mapper.deleteCustomerXiezuByIds(ids);
    }

    /**
     * 获取最大编号
     * @param customerXiezu 客户协助
     * @return 结果
     */
    @Override
    public int findMaxSort(CustomerXiezu customerXiezu)
    {
        return NumberUtils.nextOrder(mapper.findMaxSort(customerXiezu));
    }

    @Override
    public PageInfo<CustomerXiezu> findMyXieZuList(CustomerXiezu customerXiezu) {
        PageDomain page = customerXiezu.getPage();
        Integer pageNum = page.getPageNum();
        Integer pageSize = page.getPageSize();
        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
        {
            String orderBy = SqlUtil.escapeOrderBySql(page.getOrderBy());
            Boolean reasonable = page.getReasonable();
            PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
        }
        return new PageInfo(mapper.findMyXieZuList(customerXiezu));
    }

    @Override
    @Transactional(readOnly = false)
    public Integer deleteByCustomerId(CustomerXiezu customerXiezu) {
        return mapper.deleteByCustomerId(customerXiezu);
    }
}
